import fetch from '../../common/api/api'

export const FETCH_DATA = "FETCH_DATA";


export function fetchWetherData(location) {
    location = location || "beijing"
    return dispatch=> {
        fetch({
            name: 'w',
            query: {
                key: "ny8rnvjl8svz4aue",
                location: location,
                language: "zh-Hans",
                unit: "c"
            }
        }).then((res)=> {
            dispatch({
                type: FETCH_DATA,
                data: res.results[0]
            })
        });
    }
}